package com.zzptc.zzsgz.bdsjws.fragments;

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

import com.zzptc.zzsgz.bdsjws.R;
import com.zzptc.zzsgz.bdsjws.activities.AddContactsActivity;
import com.zzptc.zzsgz.bdsjws.fragments.base.BaseFragmentbase;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by zzsgz on 2017/5/27.
 */

public class SecondFragment extends BaseFragmentbase {


    @BindView(R.id.et_add)
    EditText etAdd;
    @BindView(R.id.img_add)
    ImageView imgAdd;
    @BindView(R.id.btn_yes)
    Button btnYes;
    Unbinder unbinder;


    @Override
    public void initView() {
        etAdd.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                btnYes.setVisibility(View.VISIBLE);
                imgAdd.setVisibility(View.GONE);
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });

    }

    @Override
    public void initData() {

    }

    @Override
    public int getXML() {
        return R.layout.second_fragment;
    }


    @OnClick(R.id.img_add)
    public void onViewClicked() {
        //Toast.makeText(getActivity(), "======", Toast.LENGTH_SHORT).show();
        startActivity(new Intent(getActivity(), AddContactsActivity.class));
    }



    @OnClick(R.id.btn_yes)
    public void onYesClicked() {
        //先判断电话号码的长度  并且要获取电话号码
        String tel=etAdd.getText().toString().trim();
        //判断电话号码的长度
        etAdd.setText("");
        btnYes.setVisibility(View.GONE);
        imgAdd.setVisibility(View.VISIBLE);

    }
}
